package com.cn.onetrip.activity;

import com.cn.onetrip.adapter.InfoFeastItemAdapter;
import com.cn.onetrip.activity.R;
import com.cn.onetrip.untility.Untility;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;

public class InfoFeastActivity extends Activity implements OnItemClickListener {
	public static View view;
	private ListView feastList;
	private InfoFeastItemAdapter adapter;
	private Button quit;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Window w = getWindow();
		view = w.getDecorView();
		setContentView(R.layout.activity_feast);
		feastList = (ListView) findViewById(R.id.FeastList);
		adapter = new InfoFeastItemAdapter(InfoFeastActivity.this, feastList,
				handler);
		feastList.setAdapter(adapter);
		feastList.setOnItemClickListener(this);
		quit = (Button) findViewById(R.id.quit);
		quit.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
	}

	@Override
	protected void onResume() {
		loadDate();
		super.onResume();
	}

	@Override
	protected void onPause() {
		super.onPause();
		adapter.clean();
	}

	public void loadDate() {
		adapter.clean();
		adapter.addTitleText(getResources().getString(R.string.info_feast_a));
		adapter.addTitleText(getResources().getString(R.string.info_feast_b));
		adapter.addTitleText(getResources().getString(R.string.info_feast_c));
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
			finish();
		}
		return super.onKeyDown(keyCode, event);
	}

	public Handler handler = new Handler() {
		public void dispatchMessage(android.os.Message msg) {
			if (msg.what == 0) {
			}
		};
	};
}
